﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MasterDetailTemplate.Services;

namespace MasterDetailTemplate.Models {
    /// <summary>
    /// 菜单项。
    /// By XJ
    /// </summary>
    public class MenuItem {
        private MenuItem() { }

        /// <summary>
        /// 标题。
        /// </summary>
        public string Title { get; private set; }

        /// <summary>
        /// 页面键。
        /// </summary>
        public string PageKey { get; private set; }

        public static IList<MenuItem> Items { get; } = new List<MenuItem> {
            new MenuItem
            {
                Title = "首页", PageKey = RootNavigationServiceConstants.HomePage
            },
            new MenuItem
            {
                Title = "纪念日页", PageKey = RootNavigationServiceConstants.AnniversaryPage
            },
            new MenuItem
            {
                Title = "倒数日", PageKey = RootNavigationServiceConstants.CountdownSearchPage
            },
            new MenuItem
            {
                Title = "搜索页", PageKey = RootNavigationServiceConstants.SearchPage
            },
            new MenuItem
            {
                Title = "时间轴", PageKey = RootNavigationServiceConstants.TimelinePage
            },
            new MenuItem
            {
                Title = "数据同步", PageKey = RootNavigationServiceConstants.DataSynchronizationPage
            }
        };

        private static Dictionary<string, MenuItem> ItemDictionary =
            Items.ToDictionary(p => p.PageKey, p => p);

        public static MenuItem GetMenuItem(string pageKey) =>
            ItemDictionary.ContainsKey(pageKey)
                ? ItemDictionary[pageKey]
                : null;
    }
}